<template>
	<view @click.stop="() => {}" v-if="judgeGopayOrQianyue()">
		<view
			:class="{ actionBtn: true, actionBtn0: position == 0, actionBtn1: position == 1, actionBtn2: position == 2, actionBtn3: position == 3 }"
			@click.stop="payHandler">
			{{ btnTxt }}
		</view>
	</view>
</template>

<script>
	// 去支付 & 确认支付 按钮
	import {
		checkPosition,
		notifyTopPageRefresh
	} from '../utils/checkShowBtn.js';
	import {
		getUserId,
	} from '../../../../utils/index.js';
	import PartyCover from '../../../partyCover';

	export default {
		name: 'quzhifu',
		components: {
			PartyCover
		},
		props: {
			order: {
				type: Object,
				default: {}
			}, // 订单对象
			isUsedInList: {
				type: Boolean,
				default: true
			}, // 是否使用在订单列表页面
			userOrderCashDto: {
				type: Object,
				default: null
			}
		},
		data() {
			return {
				code: '',
				userId: '',

			};
		},

		computed: {
			position: function() {
				return checkPosition.quzhifu(this.order, this.isUsedInList);
			},
			btnTxt: function() {
				return '付公证费'
			}
		},
		watch: {},
		mounted() {
			this.userId = getUserId()
		},

		methods: {
			//判断去支付或者去签约是否显示按钮
			judgeGopayOrQianyue() {
				if (this.order.signState && this.order.signStatusType == 2 && this.order.status == '13') {
					if (this.order.gzSignStatus != 1 && !this.order.gzSignUrl) {
						return true
					} else {
						return false
					}
				} else {
					return false
				}
			},

			//付公证费接口
			payHandler() {
				this.$request('order/mall/api/orderByStages/gongzhengPay', {
					orderId: this.order.orderId,
					platformType: 'H5'
				}, 'post').then((res) => {
					if (res.success) {
						// #ifdef H5
						let isIos = uni.getSystemInfoSync().platform
						if (isIos == 'ios') {
							let timer = null
							timer = setTimeout(() => {
								window.open(res.data.payUrl, '_blank')
								clearTimeout(timer);
								timer = null
							}, 10); // 延迟0.05秒
						} else {
							window.open(res.data.payUrl, '_blank')
						}
						// #endif

						// #ifdef APP-PLUS
						plus.runtime.openURL(res.data.payUrl);
						// #endif
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						});
					}
				});
			},
			partCoverCall() {
				notifyTopPageRefresh.apply(this);
			}
		}
	};
</script>

<style lang="less" scoped>
	.actionBtn {
		width: 138rpx;
		height: 56rpx;
		border-radius: 30rpx;
		border: 1px solid #c0c0c0;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 24rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #666666;
		margin-left: 24rpx;
		flex-shrink: 0;
		float: right;
		// position: absolute;
	}

	.actionBtn {
		position: relative;
	}

	.tankuang {
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 150;
		width: 100%;
		height: 600rpx;
		background-color: white;
	}


	.mengceng {
		position: fixed;
		left: 0;
		bottom: 0;
		width: 100%;
		height: 100vh;
		z-index: 100;
		opacity: 0.5;
		/* background-color: #999999; */
		background-color: #4b2323;
	}
</style>